DESTRUCTION / 94 — CAR ASSEMBLY PLAYGROUND

Run: codea run /Users/sim/Developer/NASCAR/DestructionPlayground.codea

Phone controls
  Top right EXIT        Restore FULLSCREEN mode and Codea viewer controls
  Bottom right GAS      Hold to accelerate
  Bottom left HANDBRAKE Immediate rear-wheel skid; keep holding to reverse
                        after slowing down (minimum 0.45 s handbrake pull)
  Tilt left / right     Steer, with a dead zone and smoothing
  Drag open screen      Orbit horizontally / change camera height vertically
  Tap open screen       Throw a rock on release; dragging/cancel never fires
  ZERO TILT             Centre steering at your comfortable holding angle
  AXIS AUTO             Cycle swap / invert overrides (saved on this device)
  REBUILD               Reset the car, debris and skid marks
  The open inner display's 90-degree sensor offset is handled automatically.
  Orientation changes cancel held touches and recalibrate steering.

Keyboard controls (still supported)
  WASD / arrow keys     Drive and steer directly
  S / Down              Brake while moving forward, then reverse
  Space                 Brake
  Tap / click           Shoot a large rock toward the car
  F                     Shoot at the centre of the car
  Q / E                 Orbit the camera (attack from different sides)
  C                     Toggle heading-follow / fixed-heading camera
  R                     Rebuild the car and reset the entire arena
  P                     Pause

The arena includes concrete targets, movable crate stacks, slalom posts and
launch ramps, rusty warehouses and a shipping container. CC0 Poly Haven textures
are reduced to 128 x 128 with nearest filtering; see TextureSources.txt. The 37-part Blender car retains its original paint, V8, chassis,
axles, interior and four complete tyre/rim assemblies.

Implementation
  Native physics3d rigid bodies handle chassis motion, props, rocks and debris.
  A manually stepped world runs at 120 Hz via fixedUpdate.
  Four spring/damper contacts support the car independently on the floor/ramps.
  Direct steering and tyre forces replace the racing project's lane assistance.
  Remaining wheels lose contact/grip independently. One/two-wheel operation
  uses arcade balance and reduced centre-applied drive; no wheel-count game-over.
  Lift-off braking slows the grounded car when acceleration is released.
  Losing the engine removes engine drive.
  Impacts dent panels and deplete local part health. Detached components become
  native convex rigid bodies; descendants follow a broken parent attachment.
  Panels now have 320 health (previously 85), per-hit damage limits and a smaller
  damage radius. Intact bodywork shields mechanical components.
  At 30% health panels become native hinged bodies. Ground scraping makes sparks
  and wears down the last attachment; subsequent impacts can finish it off.
  Hinges use explicit local anchors/axes on both bodies. A separation over 0.55 m
  breaks the joint instead of allowing an unstable long-distance attachment.
  Handbraking reduces rear lateral grip and disables grounded yaw assistance.
  Sliding/braking tyres lay persistent skid ribbons, capped at 1,280 segments.
  Complete tyres and rims always detach together.
  Debris retains its render mesh and uses an eight-corner collision hull to avoid
  impact-time mesh rebuilds. Surviving panel dents are spread across render frames.

Deliberate prototype simplifications
  Attached pieces share a simplified chassis collision shape rather than
  maintaining 36 live native constraints. Damage creates debris bodies on demand.
  The available 3D Lua contact callbacks do not expose a usable manifold here;
  ram damage uses sudden velocity changes, and rock damage uses a swept local
  hit region. Bullet supplies physical collision response independently.
  Suspension height queries currently support the arena floor and launch ramps;
  movable props use chassis collision rather than becoming suspension surfaces.
  Damage thresholds and dents are arcade approximations. Structure is not soft-body.
  Loose parts persist until reset. Rocks are capped at 18 and expire after 14 seconds.

Re-export saved Blender geometry (does not alter the open Blender window):
  /Applications/Blender.app/Contents/MacOS/Blender --background \
    art/destructible94/Speedway94_Destructible.blend --python-exit-code 1 \
    --python tools/export_playground_parts.py

Runner checks (these reset the current playground):
  codea exec --file tools/check_playground.lua
  codea exec --file tools/check_playground_arena.lua
  codea exec --file tools/check_playground_polish.lua
  codea exec --file tools/check_playground_touch_damage.lua
  codea exec --file tools/check_playground_hinges.lua

Verified: rest stability; straight acceleration; steering direction; projectile
and ram damage; whole-wheel loss; powered one-wheel movement after settling;
reverse; ramp launch; touched() firing; projectile cap; complete reset.

Polish checks: lift-off from 15 m/s stops below 0.15 m/s in about 2.7 s / 18 m;
sampled six-part smash CPU processing fell from about 141 ms to 2 ms. These are
local Runner measurements, not a guarantee of total frame time on every device.
Also verified dent queue drainage, small debris hulls and 128 x 128 yard textures.

Phone deployment (collections-backed Air Code):
  CODEA_HOST=192.168.4.120 CODEA_PORT=18513 codea push Documents/Destruction ‘94 --input DestructionPlayground.codea
  CODEA_HOST=192.168.4.120 CODEA_PORT=18513 codea run Documents/Destruction ‘94

Phone verification: simultaneous pedal touches, release/cancel, tap versus drag,
handbrake-to-reverse, skid marks, dents, hinged panels, scraping sparks, final
breakaway and reset. Tilt direction confirmed on device. Four loose panels were
also checked on rotated chassis at three arena positions; worst attachment gap
was 0.0382 m. An intentionally overstretched attachment broke away immediately.

Sound effects
  Original synthesized mono PCM effects in sfx_*.wav, generated with
  tools/generate_playground_audio.py; no external recordings or licenses.
  Engine pitch follows speed and throttle and stops when the engine is lost.
  Tyre squeal follows skid/handbrake intensity; scraping follows dragging metal.
  Impacts, detached parts, rock throws and ground landings trigger short effects.
  Audio.lua preloads sources, keeps three loops, caps short effects at eight
  voices, and clears playback on rebuild. Pausing silences all voices.
